package v1

import (
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/net/ghttp"
	"ruoyi-vue-pro-go/api/common"
	"ruoyi-vue-pro-go/internal/model/vo"
)

type GetOneReq struct {
	g.Meta `path:"/admin-api/system/user/get" method:"get" tags:"User" permission:"system:user:query" summary:"Get one user"`
	Id     int64 `v:"required" dc:"user id"`
}
type GetOneRes struct {
	*vo.SystemUserVO `dc:"user"`
}

type GetListReq struct {
	g.Meta `path:"/admin-api/system/user/simple-list" method:"get" tags:"User" permission:"system:user:query" summary:"Get users"`
}
type GetListRes struct {
	List []*vo.SystemUserVO `json:"list" dc:"user list"`
}

type GetOneByNameReq struct {
	g.Meta   `path:"/admin-api/system/user/{username}" method:"get" tags:"User" permission:"system:user:query" summary:"Get one user by name"`
	Username string `v:"required" dc:"user name"`
}
type GetOneByNameRes struct {
	*vo.SystemUserVO `dc:"user"`
}

type GetPageReq struct {
	g.Meta `path:"/admin-api/system/user/page" method:"get" tags:"User Page" permission:"system:user:query" summary:"Get users pages"`
	*common.CommonPageReq
	Username   string   `dc:"user name"`
	Mobile     string   `dc:"user mobile"`
	CreateTime []string `dc:"create time"`
	DeptId     int64    `d:"-1" dc:"dept id"`
}
type GetPageRes struct {
	List []*vo.SystemUserVO `json:"list" dc:"user pages"`
	*common.CommonPageRes
}

type GetPermissionListByUserIdReq struct {
	g.Meta `path:"/admin-api/system/user/permission" method:"get" tags:"User" summary:"Get user permission list"`
	UserId int64 `dc:"user id"`
}
type GetPermissionListByUserIdRes struct {
	List []string `json:"list" dc:"user permission list"`
}

type GetRoleListByUserIdReq struct {
	g.Meta `path:"/admin-api/system/user/role" method:"get" tags:"User" summary:"Get user role list"`
	UserId int64 `dc:"user id"`
}
type GetRoleListByUserIdRes struct {
	List []string `json:"list" dc:"user role list"`
}

type UpdateReq struct {
	g.Meta   `path:"/admin-api/system/user/{id}" method:"put" tags:"User" permission:"system:user:update" summary:"Update user"`
	Id       int64  `v:"required" dc:"用户ID"`
	Username string `v:"required" dc:"用户账号"`
	Password string `v:"required" dc:"密码"`
	Nickname string `v:"required" dc:"用户昵称"`
	Remark   string `dc:"备注"`
	DeptId   int64  `dc:"部门ID"`
	PostIds  string `dc:"岗位编号数组"`
	Email    string `v:"email" dc:"用户邮箱"`
	Mobile   string `v:"phone" dc:"手机号码"`
	Sex      int    `dc:"用户性别"`
	Avatar   string `v:"url" dc:"头像地址"`
	Status   int    `v:"required|in:0,1" dc:"帐号状态（0正常 1停用）"`
	TenantId int64  `dc:"租户ID"`
	Creator  string `dc:"创建人"`
	Updater  string `dc:"更新人"`
}
type UpdateRes struct{}

type CreateReq struct {
	g.Meta   `path:"/admin-api/system/user/create" method:"post" tags:"User" permission:"system:user:create" summary:"Create user"`
	Id       int64  `dc:"用户ID"`
	Username string `v:"required#用户名不能为空|unique:true" dc:"用户账号"`
	Password string `v:"required" dc:"密码"`
	Nickname string `v:"required" dc:"用户昵称"`
	Remark   string `dc:"备注"`
	DeptId   int64  `dc:"部门ID"`
	PostIds  string `dc:"岗位编号数组"`
	Email    string `v:"email" dc:"用户邮箱"`
	Mobile   string `v:"phone" dc:"手机号码"`
	Sex      int    `dc:"用户性别"`
	Avatar   string `v:"url" dc:"头像地址"`
	Status   int    `v:"required|in:0,1" dc:"帐号状态（0正常 1停用）"`
	TenantId int64  `dc:"租户ID"`
	Creator  string `dc:"创建人"`
	Updater  string `dc:"更新人"`
}
type CreateRes struct{}

type DeleteReq struct {
	g.Meta `path:"/admin-api/system/user/delete" method:"delete" tags:"User" permission:"system:user:delete" summary:"Delete user"`
	Id     int64 `v:"required"`
}
type DeleteRes struct{}

type DeleteListReq struct {
	g.Meta `path:"/admin-api/system/user/delete-list" method:"delete" tags:"User" permission:"system:user:delete" summary:"Delete user list"`
	Ids    string `v:"required"`
}
type DeleteListRes struct{}

type ExportExcelReq struct {
	g.Meta `path:"/admin-api/system/user/export-excel" method:"get" tags:"User" permission:"system:user:export" summary:"Export user excel"`
}
type ExportExcelRes struct {
	g.Meta `mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" type:"string" example:"<file content>"`
}

type DownloadTemplateReq struct {
	g.Meta `path:"/admin-api/system/user/get-import-template" method:"get" tags:"User" summary:"Download user import template"`
}

type DownloadTemplateRes struct {
	g.Meta `mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" type:"string" example:"<file content>"`
}

type ImportExcelReq struct {
	g.Meta        `path:"/admin-api/system/user/import" method:"post" mime:"multipart/form-data" tags:"User" permission:"system:user:import" summary:"Import users from excel"`
	File          *ghttp.UploadFile `type:"file" dc:"Excel文件"`
	UpdateSupport bool              `dc:"是否支持更新，默认为 false"`
}

type ImportExcelRes struct {
	Code    int                    `json:"code" dc:"状态码"`
	Message string                 `json:"message" dc:"导入结果"`
	Data    map[string]interface{} `json:"data" dc:"导入详情"`
}

type ResetPasswordReq struct {
	g.Meta   `path:"/admin-api/system/user/update-password" method:"put" tags:"User" permission:"system:user:update-password" summary:"Reset user password"`
	Id       int64  `v:"required" dc:"user id"`
	Password string `v:"required|length:4,16" dc:"password"`
}

type ResetPasswordRes struct {
}
